<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Navo Portable Library: navo/algorithm/linear/linked/dclnk.c源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 制作者 Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Navo Portable Library&#160;<span id="projectnumber">Ver 1.0.20120827</span></div>
   <div id="projectbrief">Provides generic platform independent facilities.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>数据结构</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>全局定义</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>navo/algorithm/linear/linked/dclnk.c</h1>  </div>
</div>
<div class="contents">
<a href="dclnk_8c.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="dclnk_8h.html" title="Doubly circular linked list.">dclnk.h</a>&quot;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#pragma optimize(&quot;t&quot;, on)</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#endif  </span><span class="comment">/* #ifdef _MSC_VER */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00019"></a>00019 <span class="preprocessor">#endif </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00020"></a>00020 
<a name="l00021"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gad1423b930d6c464d2ac3bb12544bc27d">00021</a> NV_IMPL <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gad1423b930d6c464d2ac3bb12544bc27d" title="判断链表结构是否正常">dclnk_check</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a>* loop_entry)
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> sprv = (<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga86953fe272bdfdf279a801822e8c681f" title="迭代器">dclnk_iter</a>)head;
<a name="l00024"></a>00024     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> fprv = (<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga86953fe272bdfdf279a801822e8c681f" title="迭代器">dclnk_iter</a>)head;
<a name="l00025"></a>00025     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> slow = head-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00026"></a>00026     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> fast = slow;
<a name="l00027"></a>00027     
<a name="l00028"></a>00028     <span class="keywordflow">while</span> (fast != head &amp;&amp; fast-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a> != head) {
<a name="l00029"></a>00029         <span class="keywordflow">if</span> (!fast || !fast-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>)
<a name="l00030"></a>00030             <span class="keywordflow">return</span> DCLNK_CHECK_NULL;
<a name="l00031"></a>00031         <span class="keywordflow">if</span> (fprv != fast-&gt;<a class="code" href="struct____dclnk__node.html#ad6444cb695c4b196b886298f9e21cc10" title="前驱节点">prev</a> || 
<a name="l00032"></a>00032             sprv != slow-&gt;<a class="code" href="struct____dclnk__node.html#ad6444cb695c4b196b886298f9e21cc10" title="前驱节点">prev</a>)
<a name="l00033"></a>00033             <span class="keywordflow">return</span> DCLNK_CHECK_LINK;
<a name="l00034"></a>00034         sprv = slow;
<a name="l00035"></a>00035         slow = slow-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00036"></a>00036         fprv = fast-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00037"></a>00037         fast = fprv-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00038"></a>00038         <span class="keywordflow">if</span> (fast == slow) {
<a name="l00039"></a>00039             <span class="keywordflow">if</span> (loop_entry) {
<a name="l00040"></a>00040                 <span class="comment">/* 获取环路入口 */</span>
<a name="l00041"></a>00041                 slow = head-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00042"></a>00042                 <span class="keywordflow">while</span> (fast != slow) {
<a name="l00043"></a>00043                     slow = slow-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00044"></a>00044                     fast = fast-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00045"></a>00045                 }
<a name="l00046"></a>00046                 *loop_entry = slow;
<a name="l00047"></a>00047             }
<a name="l00048"></a>00048             <span class="keywordflow">return</span> DCLNK_CHECK_LOOP;
<a name="l00049"></a>00049         }
<a name="l00050"></a>00050     }
<a name="l00051"></a>00051     
<a name="l00052"></a>00052     <span class="keywordflow">return</span> DCLNK_CHECK_PASS;
<a name="l00053"></a>00053 }
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 NV_IMPL <span class="keywordtype">void</span> __dclnk_iter_swap(
<a name="l00056"></a>00056     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> aprev, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> a, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> anext, 
<a name="l00057"></a>00057     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> bprev, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> b, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> bnext)
<a name="l00058"></a>00058 {
<a name="l00059"></a>00059     <span class="keywordflow">if</span> (a == bprev) {
<a name="l00060"></a>00060         <span class="comment">/* (1) b节点是a节点的后继节点</span>
<a name="l00061"></a>00061 <span class="comment">         *                               (a)</span>
<a name="l00062"></a>00062 <span class="comment">         * -(ap)-(a)-(b)-(bn)- ===&gt;                ===&gt; -(ap)-(b)-(a)-(bn)-</span>
<a name="l00063"></a>00063 <span class="comment">         *                          -(ap)-(b)-(bn)-</span>
<a name="l00064"></a>00064 <span class="comment">         */</span>
<a name="l00065"></a>00065         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga4ad181b1f8cf42e5e3ff3e9c623f22fc" title="链接两个节点">dclnk_link</a>(aprev, b);
<a name="l00066"></a>00066         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae94eb1f1c4deac0da3205273c0efdad1" title="在两个节点之间插入一个新节点">dclnk_insert_between</a>(a, b, bnext);
<a name="l00067"></a>00067     }
<a name="l00068"></a>00068     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (a == bnext) {
<a name="l00069"></a>00069         <span class="comment">/* (2) a节点是b节点的后继节点</span>
<a name="l00070"></a>00070 <span class="comment">         *                               (b)</span>
<a name="l00071"></a>00071 <span class="comment">         * -(bp)-(b)-(a)-(an)- ===&gt;                ===&gt; -(bp)-(a)-(b)-(an)-</span>
<a name="l00072"></a>00072 <span class="comment">         *                          -(bp)-(a)-(an)-</span>
<a name="l00073"></a>00073 <span class="comment">         */</span>
<a name="l00074"></a>00074         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga4ad181b1f8cf42e5e3ff3e9c623f22fc" title="链接两个节点">dclnk_link</a>(bprev, a);
<a name="l00075"></a>00075         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae94eb1f1c4deac0da3205273c0efdad1" title="在两个节点之间插入一个新节点">dclnk_insert_between</a>(b, a, anext);
<a name="l00076"></a>00076     }
<a name="l00077"></a>00077     <span class="keywordflow">else</span> {
<a name="l00078"></a>00078         <span class="comment">/* (3) a节点、b节点不相邻 </span>
<a name="l00079"></a>00079 <span class="comment">         * -(ap)-(a)-(an)-...-(bp)-(b)-(bn)- ===&gt;      (a)</span>
<a name="l00080"></a>00080 <span class="comment">         *                                        -(ap)-(b)-(an)-...-(bp) (bn)-</span>
<a name="l00081"></a>00081 <span class="comment">         *  --(ap)-(b)-(an)-...-(bp)-(a)-(bn)-- &lt;===</span>
<a name="l00082"></a>00082 <span class="comment">         */</span>
<a name="l00083"></a>00083         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae94eb1f1c4deac0da3205273c0efdad1" title="在两个节点之间插入一个新节点">dclnk_insert_between</a>(b, aprev, anext);
<a name="l00084"></a>00084         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae94eb1f1c4deac0da3205273c0efdad1" title="在两个节点之间插入一个新节点">dclnk_insert_between</a>(a, bprev, bnext);
<a name="l00085"></a>00085     }
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087 
<a name="l00088"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0de88342e30ab0e6a95b648f641c82c1">00088</a> NV_IMPL <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0de88342e30ab0e6a95b648f641c82c1" title="计算两个节点的迭代距离">dclnk_distance</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> first, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> last)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090     <span class="keywordtype">size_t</span> dist = 1;
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     <span class="keywordflow">while</span> (first != last) {
<a name="l00093"></a>00093         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaea2c7c56280acea09dafcba1aba02bb5" title="迭代器递增">dclnk_inc</a>(first);
<a name="l00094"></a>00094         ++dist;
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097     <span class="keywordflow">return</span> dist;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa4d3dc1196aa9fe3c0c044503323ac15">00100</a> NV_IMPL <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa4d3dc1196aa9fe3c0c044503323ac15" title="统计表的节点数量">dclnk_count</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head)
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102     <span class="keywordtype">size_t</span> cnt = 0;
<a name="l00103"></a>00103     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> i = head-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00104"></a>00104     
<a name="l00105"></a>00105     <span class="keywordflow">while</span> (i != head) {
<a name="l00106"></a>00106         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaea2c7c56280acea09dafcba1aba02bb5" title="迭代器递增">dclnk_inc</a>(i);
<a name="l00107"></a>00107         ++cnt;
<a name="l00108"></a>00108     }
<a name="l00109"></a>00109     
<a name="l00110"></a>00110     <span class="keywordflow">return</span> cnt;
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112 
<a name="l00113"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadffbb5e0d816b360d559414d9f96f5cf">00113</a> NV_IMPL <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadffbb5e0d816b360d559414d9f96f5cf" title="反转表">dclnk_reverse</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> i = <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga310d89f0377a31ddfec420f54ed43ea1" title="得到用于反转的起始位置的迭代器">dclnk_vbegin</a>(head);  
<a name="l00116"></a>00116     <span class="keywordflow">while</span> (i != head)
<a name="l00117"></a>00117         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadc0e328a4ae2283c8804107510b8b494" title="入栈反转">dclnk_vpush</a>(head, i);
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119 
<a name="l00120"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga221a07d76e225d9f30e664bd95a5fcd8">00120</a> NV_IMPL <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga221a07d76e225d9f30e664bd95a5fcd8" title="给迭代器增加一段距离或减小一段距离">dclnk_advance</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> cur, <span class="keywordtype">int</span> dist)
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122     <span class="keywordflow">if</span> (dist &gt; 0) {
<a name="l00123"></a>00123         <span class="comment">/* 增加 */</span>
<a name="l00124"></a>00124         <span class="keywordflow">while</span> (cur != head &amp;&amp; dist--)
<a name="l00125"></a>00125             <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaea2c7c56280acea09dafcba1aba02bb5" title="迭代器递增">dclnk_inc</a>(cur);
<a name="l00126"></a>00126     } <span class="keywordflow">else</span> {
<a name="l00127"></a>00127         <span class="comment">/* 减少 */</span>
<a name="l00128"></a>00128         <span class="keywordflow">while</span> (cur != head &amp;&amp; dist++)
<a name="l00129"></a>00129             <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaedd9b66da5685e28f99eeaecc34d3c8c" title="迭代器递减">dclnk_dec</a>(cur);
<a name="l00130"></a>00130     }
<a name="l00131"></a>00131     
<a name="l00132"></a>00132     <span class="keywordflow">return</span> cur;
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134 
<a name="l00135"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf73d46da1ca836dfd1a708f5c35122bc">00135</a> NV_IMPL <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf73d46da1ca836dfd1a708f5c35122bc" title="计算迭代器的正向索引">dclnk_index_of</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> itr)
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137     <span class="keywordtype">size_t</span> cnt = 0;
<a name="l00138"></a>00138     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> i = head-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00139"></a>00139     
<a name="l00140"></a>00140     <span class="keywordflow">while</span> (i != head &amp;&amp; i != itr) {
<a name="l00141"></a>00141         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaea2c7c56280acea09dafcba1aba02bb5" title="迭代器递增">dclnk_inc</a>(i);
<a name="l00142"></a>00142         ++cnt;
<a name="l00143"></a>00143     }
<a name="l00144"></a>00144     
<a name="l00145"></a>00145     <span class="keywordflow">return</span> cnt;
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf54726f41db556629a3c54dcede5a9f2">00148</a> NV_IMPL <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf54726f41db556629a3c54dcede5a9f2" title="计算迭代器的逆向索引">dclnk_reverse_index_of</a>(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> itr)
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150     <span class="keywordtype">size_t</span> cnt = 0;
<a name="l00151"></a>00151     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> i = head-&gt;<a class="code" href="struct____dclnk__node.html#ad6444cb695c4b196b886298f9e21cc10" title="前驱节点">prev</a>;
<a name="l00152"></a>00152     
<a name="l00153"></a>00153     <span class="keywordflow">while</span> (i != head &amp;&amp; i != itr) {
<a name="l00154"></a>00154         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaedd9b66da5685e28f99eeaecc34d3c8c" title="迭代器递减">dclnk_dec</a>(i);
<a name="l00155"></a>00155         ++cnt;
<a name="l00156"></a>00156     }
<a name="l00157"></a>00157     
<a name="l00158"></a>00158     <span class="keywordflow">return</span> cnt;
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160 
<a name="l00161"></a>00161 NV_IMPL <span class="keywordtype">void</span> __dclnk_serialize(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head, <span class="keywordtype">char</span>** buf, 
<a name="l00162"></a>00162                                 <span class="keyword">const</span> <span class="keywordtype">size_t</span> offset)
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> i = head-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00165"></a>00165     <span class="keywordflow">while</span> (i != head) {
<a name="l00166"></a>00166         *buf++ = ((<span class="keywordtype">char</span>*)i) - offset;
<a name="l00167"></a>00167         i = i-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a>;
<a name="l00168"></a>00168     }
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 NV_IMPL <span class="keywordtype">void</span> __dclnk_deserialize(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_head</a>* head, <span class="keywordtype">char</span>** buf, 
<a name="l00172"></a>00172                             <span class="keywordtype">size_t</span> cnt, <span class="keyword">const</span> <span class="keywordtype">size_t</span> offset)
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174     <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> t, p = head;
<a name="l00175"></a>00175 
<a name="l00176"></a>00176     <span class="keywordflow">if</span> (!cnt)
<a name="l00177"></a>00177         <span class="keywordflow">return</span>;
<a name="l00178"></a>00178     <span class="keywordflow">while</span> (cnt--) {
<a name="l00179"></a>00179         t = (<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga86953fe272bdfdf279a801822e8c681f" title="迭代器">dclnk_iter</a>)(*buf++ + offset);
<a name="l00180"></a>00180         p-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a> = t;
<a name="l00181"></a>00181         t-&gt;<a class="code" href="struct____dclnk__node.html#ad6444cb695c4b196b886298f9e21cc10" title="前驱节点">prev</a> = p;
<a name="l00182"></a>00182         p = t;
<a name="l00183"></a>00183     }
<a name="l00184"></a>00184     t-&gt;<a class="code" href="struct____dclnk__node.html#a7fd3e4e933fc09c588ab28b651e471c0" title="后继节点">next</a> = head;
<a name="l00185"></a>00185     head-&gt;<a class="code" href="struct____dclnk__node.html#ad6444cb695c4b196b886298f9e21cc10" title="前驱节点">prev</a> = t;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 NV_IMPL <span class="keywordtype">void</span> __dclnk_free(<a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> begin, <a class="code" href="struct____dclnk__node.html" title="双向环形链表节点">dclnk_iter</a> end, 
<a name="l00189"></a>00189                             <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga432620df92f8f8be4ac3682ae48f63bf" title="单参数回调函数指针">dclnk_pr1</a> erase_handler)
<a name="l00190"></a>00190 {
<a name="l00191"></a>00191     <span class="keywordflow">while</span> (begin != end)
<a name="l00192"></a>00192         erase_handler(<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_x8E_xAF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga098729f5dc47317dc9c20a257f2420a6" title="迭代器后自增">dclnk_inc_later</a>(begin));
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 
<a name="l00195"></a>00195 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00196"></a>00196 <span class="preprocessor"></span>}
<a name="l00197"></a>00197 <span class="preprocessor">#endif </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00198"></a>00198 
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>数据结构</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>类型定义</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated at 2015年七月16日 星期四 12:00:37 for Navo Portable Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
